<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>pybindgen.module</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="pybindgen-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="pybindgen-module.html">Package&nbsp;pybindgen</a> ::
        Module&nbsp;module
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="pybindgen.module-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module module</h1><p class="nomargin-top"><span class="codelink"><a href="pybindgen.module-pysrc.html">source&nbsp;code</a></span></p>
<p>Objects that represent -- and generate code for -- C/C++ Python 
  extension modules.</p>
  <h1 class="heading">Modules and Sub-modules</h1>
    <p>A <a href="pybindgen.module.Module-class.html" 
    class="link">Module</a> object takes care of generating the code for a 
    Python module.  The way a Python module is organized is as follows.  
    There is one &quot;root&quot; <a 
    href="pybindgen.module.Module-class.html" class="link">Module</a> 
    object. There can be any number of <a 
    href="pybindgen.module.SubModule-class.html" 
    class="link">SubModule</a>s. Sub-modules themselves can have additional
    sub-modules. Calling <a 
    href="pybindgen.module.Module-class.html#generate" 
    class="link">Module.generate</a> on the root module will trigger code 
    generation for the whole module, not only functions and types, but also
    all its sub-modules.</p>
    <p>In Python, a sub-module will appear as a <i>built-in</i> Python 
    module that is available as an attribute of its parent module.  For 
    instance, a module <i>foo</i> having a sub-module <i>xpto</i> appears 
    like this:</p>
<pre class="literalblock">
   |&gt;&gt;&gt; import foo
   |&gt;&gt;&gt; foo.xpto
   |&lt;module 'foo.xpto' (built-in)&gt;
</pre>
  <h1 class="heading">Modules and C++ namespaces</h1>
    <p>Modules can be associated with specific C++ namespaces.  This means,
    for instance, that any C++ class wrapped inside that module must belong
    to that C++ namespace.  Example:</p>
<pre class="literalblock">
   |&gt;&gt;&gt; from cppclass import *
   |&gt;&gt;&gt; mod = Module(&quot;foo&quot;, cpp_namespace=&quot;::foo&quot;)
   |&gt;&gt;&gt; mod.add_class(&quot;Bar&quot;)
   |&lt;pybindgen.CppClass 'foo::Bar'&gt;
</pre>
    <p>When we have a toplevel C++ namespace which contains another nested 
    namespace, we want to wrap the nested namespace as a Python sub-module.
    The method <a 
    href="pybindgen.module.ModuleBase-class.html#add_cpp_namespace" 
    class="link">ModuleBase.add_cpp_namespace</a> makes it easy to create 
    sub-modules for wrapping nested namespaces.  For instance:</p>
<pre class="literalblock">
   |&gt;&gt;&gt; from cppclass import *
   |&gt;&gt;&gt; mod = Module(&quot;foo&quot;, cpp_namespace=&quot;::foo&quot;)
   |&gt;&gt;&gt; submod = mod.add_cpp_namespace('xpto')
   |&gt;&gt;&gt; submod.add_class(&quot;Bar&quot;)
   |&lt;pybindgen.CppClass 'foo::xpto::Bar'&gt;
</pre>

<!-- ==================== CLASSES ==================== -->
<a name="section-Classes"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Classes</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="pybindgen.module.MultiSectionFactory-class.html" class="summary-name">MultiSectionFactory</a><br />
      Abstract base class for objects providing support for multi-section
        code generation, i.e., splitting the generated C/C++ code into 
        multiple files.
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="pybindgen.module.ModuleBase-class.html" class="summary-name">ModuleBase</a><br />
      ModuleBase objects can be indexed dictionary style to access 
        contained types.
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="pybindgen.module.Module-class.html" class="summary-name">Module</a>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="pybindgen.module.SubModule-class.html" class="summary-name">SubModule</a>
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Variables</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="__package__"></a><span class="summary-name">__package__</span> = <code title="'pybindgen'"><code class="variable-quote">'</code><code class="variable-string">pybindgen</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
</table>
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="pybindgen-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Jul 12 17:23:07 2009
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
